/*
 * Copyright(c) 2018-? the original author[Wien(luweien@aliyun.com)] or authors.
 *
 */
package org.doll.it.nora.service;

import org.doll.it.base.util.AssertUtils;
import org.doll.it.nora.dao.BackupDAO;
import org.doll.it.nora.domain.BackupDO;
import org.doll.it.sequence.enums.BusinessTypeEnum;
import org.doll.it.sequence.service.DollSequenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BackupService {

	@Autowired
	private DollSequenceService sequenceService;

	@Autowired
	private BackupDAO backupDAO;

	/**
	 * 新增
	 */
	public long insert(long originId, Object obj) {
		AssertUtils.verifyId(originId);
		AssertUtils.notNull(obj, "Recycled object is required; it must not be null");

		long id = sequenceService.nextId(BusinessTypeEnum.NORA_BACKUP);

		BackupDO backupDO = BackupDO.builder().originId(originId).obj(obj).build();
		backupDO.setId(id);

		backupDAO.insert(backupDO);
		return id;
	}
}
